#include "XSystem/XCore.h"
#include "testwindow.h"

// Initialize the window
TestWindow::TestWindow(XResourcesManager *data) : XWindow(data)
{
	// Default values
    x_positionX = 0;
    x_positionY = 0;
    x_width = 420;
    x_height = 277;

	x_windowBackground.SetImage(x_data->GetImage("gui/testwindow.png"));

    x_visible = true;

	// Create the widgets
	x_widgets["button"] = new XPushButton(data, 110, 90, 40, 40);
	x_widgets["checkbox"] = new XCheckBox(data, 310, 210);
	x_widgets["label"] = new XLabel(data, 8, 235, "What ? D: I'm just testing the labels, gee.");
	x_widgets["text"] = new XTextField(data, 50, 210, 150);

	// Set the default focus
	x_widgets["text"]->SetFocus(true);
}

// Draws the window
void TestWindow::Draw()
{
    if (x_visible)
    {
        XWindow::Draw();
    }
}

// Refresh the window
void TestWindow::CheckState(const sf::Input &input)
{
	// Check the state of the widgets
    XWindow::CheckState(input);

	if (x_widgets["button"]->state() == XG_ST_LBUTTON_RELEASED)
		std::cout << "OHHHHHHHH MAHHHHHHH GAWDDDDDDDDDDDD STOP RAPING THE BUTTON D:" << std::endl;

	if (x_widgets["checkbox"]->state() == XG_ST_LBUTTON_RELEASED)
		std::cout << "I heard you liked to check out check boxes." << std::endl;
}
